package com.woniuxy.test_collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * description: TestList <br>
 * date: 2022/2/2 9:57 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */
public class TestList {
    public static void main(String[] args) {
        test02();
    }

    public static void test01() {
        Collection<String> c = new ArrayList<>();

        System.out.println(c.size());
        System.out.println(c.isEmpty());

        System.out.println(c.contains("ss"));

        c.add("高");
        c.add("方法");
        System.out.println(c);
        System.out.println(c.size());
        System.out.println("-------");

        c.remove("高");
        System.out.println(c);
    }

    public static void test02() {
        List<String> list = new ArrayList<>();
        list.add("A");
        list.add("B");
        list.add("C");
        list.add("D");
        System.out.println(list);

        list.add(2, "上课");
        System.out.println(list);

        list.remove(2);
        System.out.println(list);

        list.set(2, "sas");
        System.out.println(list);

        System.out.println(list.get(2));
        list.add("C");
        list.add("B");
        list.add("A");
        System.out.println(list);

        System.out.println(list.indexOf("B"));
        System.out.println(list.indexOf("s"));
    }
}
